
export function commercialUserType(type) {
    //  商户类型. BASE: 基地商户; ACAPITAL: 农资商户; GENERAL: 普通用户; PRDBUY: 农产品采购方; LOAD_FLOW:助农贷款审核
    var result = ''
    switch (type) {
        case "BASE":
            result = '基地商户'
            break;
            
        case "ACAPITAL":
            result = '农资商户'
            break;

        case "GENERAL":
            result = '普通用户'
            break;

        case "PRDBUY":
            result = '农产品采购方'
            break;
        case "FUND":
            result="资金方"

            break;

        case "LOAD_FLOW":
            result = '助农贷款审核'
            break;
    }
    return result
}
export function userType (type) {
  //  PERSON: 个人; 企业: CORP
  var result = ''
  switch (type) {
      case "PERSON":
          result = '个人'
          break;
      case "CORP":
          result = '企业'
          break;
  }
  return result

}

export function statusType (type) {

    var status = '';

    switch (type) {
        case "ENABLE":
            status = '已审核';
            break;
        case "REJECT":
            status = '拒绝';
            break;
        case "DISABLE":
            status = '未审核';
            break;
    }

    return status;

}

export function materialType (type) {

    var materialType = '';

    switch (type) {
        case "CORPS":
            materialType = '农产品';
            break;
        case "APRODUCT":
            materialType = '农资产品';
            break;
    }

    return materialType;

}



export function identityStatusType (type) {

    var identityStatus = ''; 

    switch (type) { // NO: 未认证, YES: 已认证, GONING: 进行中, FAIL: 认证失败
        case "NO": 
            identityStatus = '未认证';
            break;
        case "YES":
            identityStatus = '已认证';
            break;
        case "GONING":
            identityStatus = '进行中';
            break;
        case "FAIL":
            identityStatus = '认证失败';
            break;
        
    }

    return identityStatus;

}



export function checkStatusType (type) {

    var checkStatus = '';
    
    switch (type) {
        
        case 1:
            checkStatus = '已审核';
  

            break;
        case 2:
            checkStatus = '拒绝';
 

            break;
        case 0:
            checkStatus = '未审核';
  

            break;
    }


    return checkStatus;

}

export function checkFlowStatus (type) {

    var flowStatus = '';
    
    switch (type) { //  (1:进行中;2:已关闭;3:竞价成功;4:已完成;5:线下办理)

        case 1:
            flowStatus = '进行中';
  
            break;
        
        case 2:
            flowStatus = '已关闭';
  
            break;
        case 3:
            flowStatus = '竞价成功';
 
            break;

        case 4:
            flowStatus = '已完成';

            break;
        case 5:
            flowStatus = '线下办理';
    
            break;
     
        
    }

    return flowStatus;

}


export function isPostpone (type) {
    var isPostpone = '';
    
    switch (type) { //是否延期(0:未延期;1:已延期)
        
        case 0:
            isPostpone = '未延期';
  
            break;
        case 1:
            isPostpone = '已延期';
            break;
    }
    return isPostpone;
}


export function orderStatusType (type) {
    var orderStatus = '';
    
    switch (type) { //订单状态(0:待发货;1:已发货)
        
        case 0:
            orderStatus = '待发货';
  
            break;
        case 1:
            orderStatus = '已发货';
            break;
    }
    return orderStatus;
}


export function isType (type) {
    var isType = '';
    
    switch (type) { //还款类型(0:一次性;1:分期还款)
        
        case 0:
            isType = '一次性';
  
            break;
        case 1:
            isType = '分期还款';
            break;
    }
    return isType;
}


export function homeImgType (type) {
    var homeImgType = '';
    switch (type) { 
        case '/farmProducts?type=NCP':
            homeImgType = '农产品专区';
  
            break;
        case '/farmProducts?type=NZ':
            homeImgType = '农资专区';
            break;
        case '/property':
            homeImgType = '产权专区';
            break;
        case '/shareCropland':
            homeImgType = '共享农田专区';
            break;
    }
    return homeImgType;
}

// 验证手机号码
export function checkPhoneNumber(rule, value, callback) {
    const reg = /^1[3|4|5|6|7|8|9]\d{9}$/;
    if (!value) {
      return callback(new Error('请填写手机号码！'))
    } else if (!reg.test(value)) {
      return callback(new Error('请填写正确的手机号码！'))
    }else{
      callback()
    }
  }


//验证身份证号码
export function checkIdNum(rule, value, callback) {
    const reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
    if (!value) {
      return callback(new Error('证件号码不能为空'))
    } else if (!reg.test(value)) {
      return callback(new Error('证件号码不正确'))
    } else {
      callback()
    }
}